﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="rukuadd.aspx.cs" Inherits="UI.system.page.storage.rukuadd" %>
<%@ Import Namespace="Model" %>
<%@ Import Namespace="Common" %>
<style type="text/css">
    .main{ height:100%; width:75%; margin-left:10px; float:left;}
    #img_k{width:100%;  height:auto;  position:relative;}
    #img_panel{width:auto; height:auto;}
    #img_panel  div{ float:left; margin-right:15px; position:relative; margin-bottom:10px;}
    #img_panel  div img{width:80px; height:80px; overflow:hidden; float:left; text-align:left; border:1px solid #cdcdcd; object-fit: cover;}
    #img_panel  div .delete{cursor:pointer; position:absolute; padding:0px; right:-20px; top:-8px; width:20px; height:20px; background:url(/system/img/delete.png);}
    #img_panel  div .delete img{border:0px; width:20px; height:20px;}
    #img_panel #add-photo{width:80px; height:80px; background-image:url(/system/img/add-photo.png); background-size:80px 80px;  padding-top:10px; float:left;}    
    .upload_img{ padding-top:8px;}
    #chuanpinimg{ float:left;}
    .layui-input-block textarea{ margin:0px; padding:0 0 0px 10px; line-height:25px;}
    #position select{}
</style>
<div style="margin: 15px;">
	<form class="layui-form" style="padding-left:0px;">
        <div class="layui-form-item">
			<label class="layui-form-label"><font>姓名</font><em>*</em></label>
			<div class="layui-input-block">
                <input type="text" name="username" placeholder="请输入姓名" lay-verify="required" readonly="readonly" autocomplete="off" class="layui-input" value="<%=info.Name %>" style=" background-color:#f2f2f2;">               
			</div>           
		</div>
        <div class="layui-form-item">
			<label class="layui-form-label" style="float:left;"><font>玻片数量</font><em>*</em></label>
			<div class="layui-input-block">
				<input type="text" name="bpcount" placeholder="请输入玻片数量" lay-verify="required" autocomplete="off" class="layui-input" value="<%=info.BPCount %>">
			</div>
		</div>
        <div class="layui-form-item">
			<label class="layui-form-label" style="float:left;"><font>蜡块数量</font><em>*</em></label>
			<div class="layui-input-block">
				<input type="text" name="lkcount" placeholder="请输入蜡块数量" lay-verify="required" autocomplete="off" class="layui-input" value="<%=info.LKCount %>">
			</div>
		</div>
        <div class="layui-form-item">
			<label class="layui-form-label" style="float:left;"><font>仓位</font><em>*</em></label>
			<div class="layui-input-block">
                <div style="width:90%; float:left;">
				<select id="pid" name="pid" lay-verify="required" lay-filter="sendtype">
                        <option value="请选择">请选择</option>  
                        <%foreach (PositionInfo pinfo in positionlist)
                          {
                              if (pinfo!=null)
                              {
                              %>
                        
					    <option value="<%=pinfo.ID %>" ><%=pinfo.Code %></option> 
					    <%}} %>
                        
				</select>
                </div>
                <div style="width:10%; float:left;">
                    <a class="layui-btn layui-btn-small  layui-btn-warm" style="float:right;height: 38px;line-height: 38px;" onclick="saomiao();">扫描</a>
               </div>
               <div><input id="saomiao" style="border:0px; color:#fff; height:1px;" /> </div>
			</div>            
		</div>
        <div class="layui-form-item">
			<label class="layui-form-label"><font>操作人</font><em>*</em></label>
			<div class="layui-input-block">
                <input type="text" name="username" placeholder="请输入操作人" lay-verify="required" readonly="readonly" autocomplete="off" class="layui-input" value="<%=aname %>" style=" background-color:#f2f2f2;">               
			</div>           
		</div>
        <div class="layui-form-item">
			<label class="layui-form-label" id="chuanpinimg">图片</label>
            <div class="main">
                <div id="img_k"><div id="img_panel" class="imgview"></div><div id="add-photo"></div></div>
            </div>        
		</div>		
        <div class="layui-form-item">
			<label class="layui-form-label"><font>备注</font></label>
			<div class="layui-input-block">
				<textarea name="remarks" placeholder="请输入备注" class="layui-textarea" rows="1"></textarea>
			</div>
		</div>  
		<a lay-filter="save" lay-submit style="display: none;"></a>
	</form>
</div>
<script>
       Init_Annex();
        function Init_Annex() {
            var Imgs = <%=Imgs %>;
            $('#img_k').html('<div id="img_panel" class="imgview"></div><div id="add-photo"></div>');
            if(Imgs != 0){
                var data = JSON.stringify(Imgs);
                var jsonData = JSON.parse(data);
                var st = jsonData;
                var str = new Array();
                str = st.toString().split(',');
                var html = "";                
                for(var i=0;i<str.length;i++){
                    html += '<div id="Imgs"><img data-original="' + str[i] + '" src="' + str[i] + '"/><input type="hidden" value="'+str[i]+'"><div id="' + str[i] + '" class="delete" onclick="RemoveFile(this)"></div></div>';
                }
                $("#img_panel").html(html);               
            } else {
                //$("#img_panel").html("暂无图片&nbsp;&nbsp;");
            }
            var upload = new Upload_File("add-photo", null, 80, 80, "/system/img/add-photo.png", true);
            upload.swfu.handle = "upload_annex";
        };
//    /* 获取仓位 */
//        function cangwei(){
//            var pcode = $("#position").val();            
//            var pid;
//            var data = {};
//            data.act = "Find_PositionByPcode";
//            data.pcode = pcode;
//            data.sign = GetSign(data.act);
//            Ajax.Post("/tools/Admin.ashx", data, function (r) {
//                var json = $.parseJSON(r);
//                pid = json.data;
//                $("#pid").val(pid);
//            });      
//        }

        function saomiao(){
            $("#saomiao").val("");
            $("#saomiao").focus();            
             $("#saomiao").keydown(function(event) {
                if(event.keyCode == "13") {
                    var array = new Array();  //定义数组     
                     $("#pid option").each(function(){  //遍历所有option    
                          var channlVal= $(this).text();   //获取option值     
                          if(channlVal!=''){    
                               array.push(channlVal);  //添加到数组中    
                          }    
                     })
                    var values =array;                       
                    var va = $("#saomiao").val();

                    var str = new Array();
                    str = values.toString().split(',');
                    var bo = 0;
                    for (var i = 0; i < str.length; i++) {                    
                        if(va == str[i] )
                        {   
                            bo=1;
                        }
                    }
                
                    $("#pid option:selected").removeAttr("selected");
                    //$("#pid").find("option:contains(请选择)").removeAttr("selected");
                    

                    if(bo>0){                    
                        $("#pid").find("option:contains("+va+")").prop("selected",true);
                        $("#pid").find("option:contains("+va+")").siblings().prop("selected",false);                    
                    }else{
                        $("#pid").find("option:contains(请选择)").prop("selected",true);    
                        $("#pid").find("option:contains(请选择)").siblings().prop("selected",false);                      
                        LayerBox.Error("没有找到该仓位");
                    }
                    form.render();

                }
            });
        }
//        document.onkeydown = function (event) {
//            var e = event || window.event || arguments.callee.caller.arguments[0];
//            if (e && e.keyCode == 13) { // enter 键
//                 var array = new Array();  //定义数组     
//                 $("#pid option").each(function(){  //遍历所有option    
//                      var channlVal= $(this).text();   //获取option值     
//                      if(channlVal!=''){    
//                           array.push(channlVal);  //添加到数组中    
//                      }    
//                 })
//                var values =array;                       
//                var va = $("#saomiao").val();

//                var str = new Array();
//                str = values.toString().split(',');
//                var bo = 0;
//                for (var i = 0; i < str.length; i++) {                    
//                    if(va == str[i] )
//                    {   
//                        bo=1;
//                    }
//                }
//                
//                $("#pid option:selected").removeAttr("selected");
//                //$("#pid").find("option:contains(请选择)").removeAttr("selected");
//                    

//                if(bo>0){                    
//                    $("#pid").find("option:contains("+va+")").prop("selected",true);
//                    $("#pid").find("option:contains("+va+")").siblings().prop("selected",false);                    
//                }else{
//                    $("#pid").find("option:contains(请选择)").prop("selected",true);    
//                    $("#pid").find("option:contains(请选择)").siblings().prop("selected",false);                      
//                    LayerBox.Error("没有找到该仓位");
//                }
//                form.render();

//            }
//        };
</script>
